import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/Login.vue'
import Layout from "@/views/Layout/Layout.vue"
import Home from '@/views/Home/Home.vue'
import Category from '@/views/Category/Category.vue'
import SubCategory from '@/views/SubCategory/SubCategory.vue'
import Detail from '@/views/Detail/Detail.vue'
import CartList from '@/views/CartList/CartList.vue'
import Checkout from '@/views/Checkout/Checkout.vue'
import Pay from '@/views/Pay/Pay.vue'
import PayBack from '@/views/Pay/PayBack.vue'
import Member from '@/views/Member/Member.vue'
import UserInfo from '@/views/Member/components/UserInfo.vue'
import UserOrder from '@/views/Member/components/UserOrder.vue'
import MySku from '@/components/XtxSku/MySku.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  redirect: '/mysku',
  routes: [
    {
      path: '/',
      component: Layout,

      children:[
        {
          path: '',
          component: Home,
        },
        {
          path: '/category/:id',
          component: Category,
        },
        {
          path: '/category/sub/:id',
          component: SubCategory,
        },
        {
          path: '/detail/:id',
          component: Detail
        },
        {
          path: '/cartList',
          component: CartList
        },
        {
          path: '/checkout',
          component: Checkout,
        },
        {
          path: '/pay',
          component: Pay,
        },
        {
          path: '/paycallback',
          component: PayBack,
        },
        {
          path: '/member',
          component: Member,
          redirect: '/member/user',
          children: [
            {
              path: '/member/user',
              component: UserInfo,
            },
            {
              path: 'order',
              component: UserOrder,
            }
          ]
        }
      ]
    },
    {
      path: '/login',
      component: Login,
    },
    {
      path: '/mysku',
      component: MySku
    }
  ],
  scrollBehavior(){
    return{
      top: 0,
    }
  }
})

export default router
